package com.twohand.admin.Entity;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@ApiModel("项目表")
@TableName("project")
@Data
public class Project extends BaseEntity{
    @ApiModelProperty(name = "项目名称")
    String title;
    @ApiModelProperty(name = "描述")
    String description;
    @ApiModelProperty(name = "banner图")
    String banner = "/img/default.png";
    @ApiModelProperty(name = "详情地址")
    @TableField(value = "detail_url")
    String detailUrl = "/project-detail";
    @ApiModelProperty(name = "在线地址")
    @TableField(value = "demo_url")
    String demoUrl = "";
    @ApiModelProperty(name = "数组 json字符串 包含图片链接与描述")
    @TableField(value = "img_list")
    JSONArray imgList = new JSONArray();
    @ApiModelProperty(name = "权重")
    Integer weight = 0;
    @ApiModelProperty(name = "是否显示 1显示 0隐藏")
    @TableField(value = "is_show")
    Integer isShow = 0;


    public String getImgList(){
        String text = JSON.toJSONString(this.imgList);
        System.out.println("-----------get:------"+this.imgList);
        return text;
    }
    public void setImgList(String imgList){
        JSONArray jsonArray = JSON.parseArray(imgList);
        System.out.println("--------解析后"+jsonArray);
        this.imgList = jsonArray;
    }
    public void setBanner(String value){
        if(value == ""){
            value = "/img/default.png";
        }
        this.banner = value;
    }
}
